﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<GabageFactory.Models.Apply>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	申请修改数据详情
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%
        RoleEnum role = (RoleEnum)ViewData["role"];
    %>
    <% using (Html.BeginForm("Process", "Modification", FormMethod.Post, new { id = "processForm" }))
    {%>
        <%= Html.ValidationSummary(true) %>
        <%= Html.HiddenFor(model => model.Id) %>
        <%= Html.Hidden("Action", "approve") %>
            
    <h2>申请修改数据详情</h2>

    <table cellpadding="4" cellspacing="0" class="com_detail_table" style="width:756px; font-size:13px;">
        <tr>
            <td class="lab" style="width:100px;"><strong>所属公司：</strong></td>
            <td><%=Model.FactoryName %></td>
        </tr>
        <tr>
            <td class="lab"><strong>申请人：</strong></td>
            <td><%=Model.Applier %></td>
        </tr>
        <tr>
            <td class="lab"><strong>申请类型：</strong></td>
            <td>
                <input type="radio" name="type" disabled="disabled" <%if (Model.type == 1){ %>checked="checked"<%} %> value="1" id="simple" onclick="applySimpleChange();" />申请修改少量历史数据
                <input type="radio" name="type" disabled="disabled" <%if (Model.type == 2){ %>checked="checked"<%} %> value="2" id="missed" onclick="applyMissedChange();" style="margin-left:20px" />申请历史数据的补录
            </td>
        </tr>
        <tr>
            <td class="lab"><strong>处理状态：</strong></td>
            <td><%=(Model.Status)%></td>
        </tr>
        <%if (Model.Status == "已拒绝"){ %>
        <tr>
           <td class="lab"><strong>拒绝原因：</strong></td>
           <td><%= Html.DisplayFor(model => model.Reason)%></td>
        </tr>
        <%} %>
        <tr>
            <td class="lab"><strong>申请标题：</strong></td>
            <td><%= Html.DisplayFor(model => model.Title)%></td>
        </tr>
        <tr>
            <td class="lab"><strong>申请内容：</strong></td>
            <td><%= Html.TextAreaFor(model => model.Content, new { disabled="disabled", cols=50, rows=12, id="content"})%></td>
        </tr>
        <tr id="missedFile" <%if (Model.type == 1){ %>style="display:none"<%} %>>
            <td class="lab"><strong>补录数据：</strong></td>
            <td><%if(!string.IsNullOrEmpty(Model.File)) {%><label class="icon_11"><a href="<%=Url.Content(Model.File) %>" target="_blank">查看附件</a></label><%} %></td>
        </tr>
        <%
            if (Model.Status == "等待审批")
            {
        %>
        <tr>
            <td>&nbsp;</td>
            <td><input type="radio" checked="checked" name="actoinType" value="1" onclick='$("#Action").val("approve");$("#rejectResonTr").css("display", "none");' />同意 <input type="radio" style="margin-left:15px" name="actoinType" value="0" onclick='$("#Action").val("reject");$("#rejectResonTr").css("display", "block");' />拒绝</td>
        </tr>
        <tr id="rejectResonTr" style="display:none">
           <td class="lab"><strong>拒绝原因：</strong></td>
           <td><%= Html.TextAreaFor(model => model.Reason, new { rows = 5, cols = 50 })%></td>
        </tr>
        <%
            }
        %>

    </table>
    
    <div class="submit_btn_area" style="margin-left:112px;">
        <%if (role == RoleEnum.Auditor && Model.Status == "等待审批") { %>
        <input type="button" value="确 定" onclick="approveOrReject();" />
        <%}
          else if (role == RoleEnum.Administrator && Model.Status == "已批准")
          {%>
        <input type="button" value="修改数据" onclick="process();" />
        <input type="button" value="完 成" onclick="finish();" />
        <%} %>
    </div>

    <% } %>

    <script type="text/javascript" language="javascript">
        function process() {
            window.open('<%=Url.Content("~/Modification/SelectFactory") %>');
        }

        function approveOrReject() {
            if ($("#Action").val() == "approve") {
                approve();
            }
            else if ($("#Action").val() == "reject") {
                reject();
            }
        }

        function approve() {
            $("#Action").val("approve");
            $("#processForm").submit();
        }

        function reject() {
            var reason = document.getElementById("Reason").value;
            if (reason == null || reason == "" || reason == undefined) {
                alert("请填写拒绝原因。");
                document.getElementById("Reason").focus();
                return;
            }
            $("#Action").val("reject");
            $("#processForm").submit();
        }

        function finish() {
            $("#Action").val("finish");
            $("#processForm").submit();
        }
    </script>
</asp:Content>

